<template>
  <el-button-group>
    <epx-button
      v-for="(item, index) in items"
      :key="item.name || index"
      :disabled="disable(item)"
      v-bind="item"
      :row="row"
      @command="command"
    />
    <slot />
  </el-button-group>
</template>
<script lang="ts" setup>
  import { Button } from './button';
  import { isDisabled, Row } from '../elementui';
  import { CommandOptions } from '../core';
  import EpxButton from './EpxButton.vue';

  const props = defineProps<{
    items: Array<Button>;
    row?: Row;
  }>();

  const emit = defineEmits(['command']);

  function disable(item: Button): boolean {
    return isDisabled(item, props.row);
  }
  function command(c: CommandOptions) {
    emit('command', c);
  }
</script>

<style scoped></style>
